/**
 * 分析一下这个程序的输出
 *
 * @author mashibing
 */
package yxxy.c_001;

public class SynchronizedTest5 implements Runnable {

    private int count = 10;

    /**
     * 不加锁，则不能保证整个方法的原子性
     */
    @Override
    public void run() {
        count--;
        //···
        System.out.println(Thread.currentThread().getName() + " count = " + count);
    }

    public static void main(String[] args) {
        SynchronizedTest5 t = new SynchronizedTest5();
        for (int i = 1; i <= 8; i++) {
            new Thread(t, "THREAD" + i).start();
        }
    }

}
